package CalcImpl;

import java.io.BufferedReader;
import java.io.FileReader;

import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;

import calculatrice.Calculatrice;
import calculatrice.CalculatriceHelper;

public class CalcClient {
	static Calculatrice href;
	
	public static void main(String args[]) {
		try {
			ORB orb = ORB.init(args, null);
			
			BufferedReader br = new BufferedReader(new FileReader("FicPourIOR"));
			String ior = br.readLine();

			br.close();
			Object obj = orb.string_to_object(ior);
			href = CalculatriceHelper.narrow(obj);
			
			for (int i = 0; i <= 10; i++) {
				short a = (short) (1 + (Math.random() * ((99) + 1)));
				short b = (short) (1 + (Math.random() * ((99) + 1)));
				
				System.out.println("Pour les nombres : " + a + " et " + b);
				System.out.println(" - Addition " + href.add(a, b));
				System.out.println(" - Soutraction " + href.sub(a, b));
				System.out.println(" - Multiplication " + href.mul(a, b));
				System.out.println(" - Division " + href.div(a, b));
				
				System.out.println("-----------------------------------------------------");
				
			}
			
		} catch (Exception e) {
			e.printStackTrace(System.out);
		}
	}
}
